package com.lanou.musicbox.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lanou.musicbox.R;
import com.lanou.musicbox.bean.EnterTheSongs;

import java.util.List;

/**
 * Created by 赵宝龙 on 15/10/22.
 * 进入歌单页面adapter
 */
public class EnterTheSongsAdapter extends BaseAdapter {
    private EnterTheSongs data;
    private List<EnterTheSongs.ContentEntity> datas;
    private Context mContext;

    public EnterTheSongsAdapter(EnterTheSongs data, Context mContext) {
        this.data = data;
        datas = data.getContent();
        Log.e("ZBL","^^^^^^^^^^^^^^" + data.getTitle());
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return datas != null && datas.size() > 0 ? datas.size() : 0;
    }

    @Override
    public Object getItem(int i) {
        return datas != null && datas.size() > 0 ? datas.get(i) : null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view==null) {
            view = LayoutInflater.from(mContext).inflate(R.layout.enterthe_songs_item, null);
            holder = new ViewHolder();
            holder.list_title = (TextView) view.findViewById(R.id.list_title);
            holder.list_author = (TextView) view.findViewById(R.id.list_author);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        if (data != null) {

            holder.list_title.setText(data.getContent().get(i).getTitle());
            holder.list_author.setText(data.getContent().get(i).getAuthor());
        }
        return view;
    }

    private class ViewHolder {
        private TextView list_title, list_author;
    }
}
